package com.jh.channel.pojo.fastsilver;

import static com.google.common.base.Strings.isNullOrEmpty;

public enum LoginStatus {

    /** 注册中 */
    PENDING("PENDING", "注册中"),

    /** 注册成功 */
    SUCCESS("SUCCESS", "注册成功"),

    /** 注册失败 */
    FAIL("FAIL", "注册失败"),
    ;

    final String value;
    final String desc;

    LoginStatus(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static LoginStatus of(String val) {
        return of(val, null);
    }

    public static LoginStatus of(String val, LoginStatus defaultStatus) {
        if (isNullOrEmpty(val)) {
            return defaultStatus;
        }
        val = val.toUpperCase();
        for (LoginStatus os : values()) {
            if (val.equals(os.getValue().toUpperCase())) {
                return os;
            }
        }
        return defaultStatus;
    }


}
